print("------------ 单一表达式作为函数值可以省略return关键字 ------------")
func greeting(person: String) -> String {
    "Hello, " + person + "!"
}
print(greeting(person: "Felix"))

print("------------ 返回可选项元祖 ------------")
func minMax(array: [Int]) -> (min: Int, max: Int)? {
    if array.isEmpty {
        return nil
    }
    var minValue = array[0]
    var maxValue = array[0]
    for value in array {
        if value < minValue {
            minValue = value
            continue
        }
        if value > maxValue {
            maxValue = value
        }
    }
    return (minValue, maxValue)
}

if let res = minMax(array: [1, 2, 44, 5, 6567, 11, -1]) {
    print(res)
}

if let res = minMax(array: []) {
    print(res)
} else {
    print("空数组")
}

print("------------ 函数类型 ------------")
// (Int, Int) -> Int
func addNum(num1: Int, num2: Int) -> Int {
    num1 + num2
}
var add: (Int, Int) -> Int = addNum
print(add(1, 2))
